#ifndef GLPP_ARRAY_OBJECT_HPP
#define GLPP_ARRAY_OBJECT_HPP

#include "../PhoenixInitializer.hpp"
#include <vector>
#include <assimp/scene.h>
#include "Material.hpp"

namespace phx { class Model; }

namespace gl
{

class ArrayObject
{
public:
	static enum StoreType : unsigned char
	{
		STATIC,
		STREAM,
		DYNAMIC
	};

	static enum RenderMode : unsigned char
	{
		VERTICES,
		INDICES
	};

	ArrayObject();

	//BufferObject*		createBufferObject(); // Create a BufferObject and set mVao in it to this ArrayObject mVao
	bool		setVertices(const std::vector<float> &vertices, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);
	bool		setIndices(const std::vector<unsigned int> &indices, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);
	bool		setNormals(const std::vector<float> &normals, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);
	bool		setTexCoords(const std::vector<float> &texCoords, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);

	bool		setSubVertices(const std::vector<float> &vertices, unsigned int offset);
	bool		setSubIndices(const std::vector<unsigned int> &indices, unsigned int offset);
	bool		setSubNormals(const std::vector<float> &normals, unsigned int offset);

	void		render();

	~ArrayObject();

	friend class phx::Model;
private:
	bool		setVertices(const aiVector3D *vertices, unsigned int size, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);
	bool		setNormals(const aiVector3D *normals, unsigned int size, ArrayObject::StoreType storeType = ArrayObject::StoreType::STATIC);
private:
	ArrayObject::RenderMode mRenderMode;
	bool mPositionAttributeActivated, mNormalAttributeActivated, mIndexDataSet, mTexCoordAttributeActivated;
	GLuint mVao, mVbo, mEbo, mNbo, mTbo;
	GLuint mDrawByteCount;

	gl::Material mMaterial;
};

}

#endif